$.extend( $.validator.defaults, {
    tipClass: "tip",
    tipElement: "span",
    tipPlacement: function(element,tip) {
        //alert(this.tipClass);
        $(element).parent().append(tip);
    }
});

/*******************************插件新功能-设置插件validator的默认参数*****************************************/
$.validator.setDefaults({
    /*关闭键盘输入时的实时校验*/
    onkeyup: null,

    /*重写校验元素获得焦点后的执行函数--增加[1.光标移入元素时的帮助提示,2.校验元素的高亮显示]两个功能点*/
    onfocusin: function( element ) {
        this.lastActive = element;
        /*1.帮助提示功能*/
        var vtip = $(element).attr('tip');
        if(vtip!='' && vtip!=undefined){
            this.addWrapper(this.errorsFor(element)).hide();
        }
        var tip="<"+this.settings.tipElement+" id='tipwy' class='"+this.settings.tipClass+"'>" + vtip + "</"+this.settings.tipElement+">";
        //alert(this.settings.tipClass);
        if(tip && $("#tipwy").length === 0){
            //$(element).parent().append("<span class='tip'>" + tip + "</span>");
            if(vtip!='' && vtip!=undefined){
                this.settings.tipPlacement(element,tip);
            }
        }
        /*2.校验元素的高亮显示*/
        //$(element).addClass('highlight');

        // Hide error label and remove error class on focus if enabled
        if ( this.settings.focusCleanup ) {
            if ( this.settings.unhighlight ) {
                this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
            }
            this.hideThese( this.errorsFor( element ) );
        }
    },
    /*重写校验元素焦点离开时的执行函数--移除[1.添加的帮助提示,2.校验元素的高亮显示]*/
    onfocusout: function( element ) {
        /*1.帮助提示信息移除*/
        $("#tipwy").remove();

        /*2.校验元素高亮样式移除*/
        //$(element).removeClass('highlight');
        
        /*3.替换下面注释的原始代码，任何时候光标离开元素都触发校验功能*/
        //this.element( element );
        
        if ( !this.checkable( element ) && ( element.name in this.submitted || !this.optional( element ) ) ) {
            this.element( element );
        }
    }
});
